Programming > General

[SOLVED] fpPDF -> add existing PDF ?

(1/2) > >>

scons:
Hi all,

I am playing around with fpPDF, so far, so good.

Now I have a question : In most pdf's text is selectable. Is it possible to add an existing pdf in fpPDF and keep this functionality ? (add existing pdf in its original state)

I was able to convert an existing pdf to a PNG and add it but then it is (of course) not possible anymore to select something from the original pdf.

So if someone can point me in the right direction, would be appreciated.

Thanks.

Ondrej Pokorny:

--- Quote from: scons on August 15, 2018, 10:09:08 am ---I was able to convert an existing pdf to a PNG and add it but then it is (of course) not possible anymore to select something from the original pdf.

--- End quote ---

Sorry for the off-topic: what tool did you use to convert PDF into PNG?

scons:
No Problem

I started with ImageMagick, then PascalMagick, but ran into a few missing parts that would make it more convenient, maybe I will go back to this route once the package gets an upgrade. But after upgrading to a later version of GhostScript it ran noticably slower for some reason, which was a little strange.

Then I played around with MuPDF.

The last one was/is Xpdf. For now I will keep Xpdf.

It is an ongoing process, I try spend some (rare) free time on this subject.

scons:
Ok I have 2 follow-up questions:


* I'm trying to change the format to a custom format, how do I have to add the H and W ? (code below)
* If I want to add more "default paper size, lets say sizes A0 -> A4, I add them to the source file (ptA0, ptA1,  + sizes) and then ... ?

--- Code: Pascal  window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1; {$mode objfpc}{$H+} uses  Classes,  fpPDF { you can add units after this }; var  PDF: TPDFDocument;  page: TPDFPage;  section: TPDFSection;  IDX: Integer;  W, H: Integer; begin  PDF := TPDFDocument.Create(nil);  try    PDF.StartDocument;    section := PDF.Sections.AddSection;    page := PDF.Pages.AddPage;    page.Orientation:= ppoLandscape;    page.Orientation:= ppoLandscape;    page.UnitOfMeasure:= uomPixels;    page.PaperType:= ptCustom;     //  define here width (W) and height (H) ?    //  page.Paper.H:= a value; -> doesn't seem to work ?     section.AddPage(page);     IDX := PDF.Images.AddFromFile('C:\Temp\test.png');    W := PDF.Images[IDX].Width;    H := PDF.Images[IDX].Height;    page.DrawImageRawSize(0, 0, W, H, IDX);     PDF.SaveToFile('C:\Temp\test.pdf');  finally    PDF.Free;  end;end. 
Thanks

rick2691:
Saw this on the fpPDF site.
http://www.fpdf.org/en/doc/__construct.htm

You set custom height and width by sending an array. Example is at the bottom.


--- Quote ---__construct
__construct([string orientation [, string unit [, mixed size]]])
Description
This is the class constructor. It allows to set up the page size, the orientation and the unit of measure used in all methods (except for font sizes).
Parameters

orientation
    Default page orientation. Possible values are (case insensitive):

        P or Portrait
        L or Landscape

    Default value is P.
unit
    User unit. Possible values are:

        pt: point
        mm: millimeter
        cm: centimeter
        in: inch

    A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.

    Default value is mm.
size
    The size used for pages. It can be either one of the following values (case insensitive):

        A3
        A4
        A5
        Letter
        Legal

    or an array containing the width and the height (expressed in the unit given by unit).

    Default value is A4.

Example
Example with a custom 100x150 mm page size:

$pdf = new FPDF('P','mm',array(100,150));



--- End quote ---

Rick

Navigation

[0] Message Index

[#] Next page

Go to full version