You are not logged in.
Pages: 1
Hello!
I have problem converting multipage Tiff to PDF. If all page in pdf have one resolution then everything is converted normally, if pages have different resolution, then i have in
lPdf.DefaultPageWidth:=TIFF_Im.Width;
lPdf.DefaultPageHeight:=TIFF_Im.Height;
only resolution from the fist page.
sorry for bad english.
program tiff_test;
{$APPTYPE CONSOLE}
uses
SysUtils,
SynGDIPlus,
SynPDF,
Classes;
var
lPdf : TPdfDocument;
TIFF_Im:TTIFFImage;
PDF_Im: TPdfImage;
i:integer;
pdfpage: TPdfpage;
Im_Ox:string;
begin
lPdf := TPdfDocument.Create;
TIFF_Im:=TTIFFImage.Create;
TIFF_Im.LoadFromFile('c:\tiff\1.tif');
for i:=0 to TIFF_Im.GetPageCount-1 do
begin
TIFF_Im.ActivePageIndex:=i;
lPdf.DefaultPageWidth:=TIFF_Im.Width;
lPdf.DefaultPageHeight:=TIFF_Im.Height;
pdfpage:=lPDF.AddPage;
PDF_Im:= TPdfImage.Create (lPDF, TIFF_Im, true);
Im_Ox:='Im'+IntToStr(i);
lPDF.AddXObject(Im_Ox,PDF_Im);
lpdf.Canvas.DrawXObject (0,0, lPdf.DefaultPageWidth, lPdf.DefaultPageHeight, Im_Ox);
writeln('converting ', i, ' page');
end;
lPDF.SaveToFile('c:\SynPDFTest.pdf');
end.
best regards, Vladimir
Last edited by Vladimir K. (2019-02-13 06:27:56)
Offline
Offline
Hello, Chaa
I have one multipage tiff file, 1 - 6 pages 595x842 pix, and 7-9 pages 2380x1684 pix (after converting to 72 dpi).
TiffImage return 595x842 for all pages, not paying attention to either the size or the orientation of the page.
drawings on pages 7-9 are elongated (due to incorrect page orientation)
what you propose is working with a list of files.
Offline
Did you try to set ForceNoBitmapReuse := true ?
Now I tried to force the installation of ForceNoBitmapReuse in both TRUE and FALSE, there is no result.
As I understand the wrong size of the image gives Tiffimage in TIFF_Im.Width and TIFF_Im.Height.
Offline
Try to add call to procedure fImageSet in the end of TTiffImage.SelectPage.
Offline
Try to add call to procedure fImageSet in the end of TTiffImage.SelectPage.
Thanks, now everything works out correctly. SynGDIPlus now looks like this.
procedure TTiffImage.SelectPage(index: integer);
var wFrames: integer;
begin
wFrames := GetPageCount;
if (wFrames>0) and (cardinal(index)<cardinal(wFrames)) then begin
Gdip.SelectActiveFrame(fImage, @FrameDimensionPage, index);
fActivePage := index;
end else
raise ERangeError.Create('Invalid Page Index');
//***** Add for correct file resolution *****
fImageSet;
// **********************************
end;
Now I will think how to make the text semitransparent, to create an analogue of watermarks. As I understand it is better to do through VCLCanvas.
Offline
Pages: 1