Emiel Wieldraaijer Posted September 25, 2013 Share Posted September 25, 2013 (edited) Hi ErikE83, I don't know the solution (yet) but it has something to do with the byte offset not being correct inside the PDF http://forums.adobe.com/thread/998718 Open the file and save it .. and the problem is solved .. Edit : Foxit PDFReader does not want to save the file when closing Edited September 26, 2013 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
corgano Posted November 8, 2013 Share Posted November 8, 2013 Is there any documentation available for this? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted November 8, 2013 Share Posted November 8, 2013 See UDF and Examples Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Qwerty212 Posted November 16, 2013 Share Posted November 16, 2013 Hello again from Barcelona I'm doing a little script to pass data from an Excel file to a PDF and also create and embed QR codes inside the PDF file. I read the data from the Excel succefully and I do also create the QR codes as .bmp images (because we can't create pure pdf qr codes yet with this method) As the Excel file is generated as report by another program, the amount of data will be different everytime. I'm trying to add data to the PDF as I'm getting it from the excel file, but I have noticed that I just can not begin a pdf page, load the image that I have just created and insert it in the right place in the pdf: _BeginPage();I do start the page Sleep(25) _LoadResImage("Cod", @ScriptDir & "\QR\1.bmp") Sleep(25) _InsertImage("Cod", 16, 26, 3.5, 3.5) The code above doesn't work. If you do this: _LoadResImage("Cod", @ScriptDir & "\QR\1.bmp") Sleep(25) _BeginPage() _InsertImage("Cod", 16, 26, 3.5, 3.5) It works like a charm. Any hint or clue about how can I create the page first and load the images as I'm creating the QR codes? Thanks in advance. Link to comment Share on other sites More sharing options...
vinyking Posted December 13, 2013 Share Posted December 13, 2013 I am new to Autoit. - I have alltogether 2 weeks expossure and few codding expereience, I will like to print /Save a web page in PDF format. only wondering if this could be achieed. Any help will be appreciated. Vin Link to comment Share on other sites More sharing options...
ShawnW Posted January 16, 2014 Share Posted January 16, 2014 Well looks like I stumbled on a need for this a year to late since the original poster seems to not be around anymore but I just want to say Awesome Work!!! Some improvements that are needed from what I have seen so far, and I may have to write them myself for what I need are... Make _ClosePDFFile() clear the buffers so that resources from one pdf do not get loaded into subsequent pdfs and cause larger and larger files the more you create. Since all the stuff gets written at the end, and since order maters as seen in >#224, why not keep a separate buffer for resources that you can put in order later when writing. That way you can loop through some data and dynamically load and insert images within a page, rather than loop to load, then start the page and loop again to insert. Other notes that are just me being picky take udf out of the name, no other udf has udf in the name. Start the function names with a common identifier like _MPDFDrawLine, _MPDFPath,... So users can easily know what the function is referencing. Link to comment Share on other sites More sharing options...
Qwerty212 Posted January 17, 2014 Share Posted January 17, 2014 Well looks like I stumbled on a need for this a year to late since the original poster seems to not be around anymore but I just want to say Awesome Work!!! Some improvements that are needed from what I have seen so far, and I may have to write them myself for what I need are... Make _ClosePDFFile() clear the buffers so that resources from one pdf do not get loaded into subsequent pdfs and cause larger and larger files the more you create. Since all the stuff gets written at the end, and since order maters as seen in >#224, why not keep a separate buffer for resources that you can put in order later when writing. That way you can loop through some data and dynamically load and insert images within a page, rather than loop to load, then start the page and loop again to insert. Other notes that are just me being picky take udf out of the name, no other udf has udf in the name. Start the function names with a common identifier like _MPDFDrawLine, _MPDFPath,... So users can easily know what the function is referencing. Any chance of getting no compression on images embedded? Thanks a lot for keeping the work. Link to comment Share on other sites More sharing options...
ryadical Posted January 30, 2014 Share Posted January 30, 2014 I think I may have found a bug but I was wondering if perhaps I just need to modify the example code. I used the included example file (Example_Image2PDF.au3) to try and convert a multi-page TIF file and it only converted the first page. Can anyone with more knowledge of TIF, PDF and MPDF_UDF chime in on where they think the problem might be? I have not done much digging into the MPDF code to see if I could figure out how to do it. I did find an example on changing a multipage tiff to pdf using 3 different DLL's ( I would rather keep using this UDF because I am also converting other image files as well. Link to comment Share on other sites More sharing options...
dmob Posted February 3, 2014 Share Posted February 3, 2014 @ryadical I use IrfanView via its command line interface to temporarily extract the pages then process them individually in a loop. Link to comment Share on other sites More sharing options...
mLipok Posted February 3, 2014 Share Posted February 3, 2014 I am new to Autoit. - I have alltogether 2 weeks expossure and few codding expereience, I will like to print /Save a web page in PDF format. only wondering if this could be achieed. Any help will be appreciated. Vin search forum for PDFCreator Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
bdr529 Posted March 10, 2014 Share Posted March 10, 2014 I'm sorry but I do not write in English I need to google translator I read this document http://books.google.it/books?id=1TpDgwNGIK8C&pg=PA28&lpg=PA28&dq=cross-reference+table+corrupted+file+pdf&source=bl&ots=oFAVUiJD-T&sig=RWW2bQkS04Q-v7U5aMTK4qwY944&hl=it&sa=X&ei=hogcU_-iEqvpywO654DgBA&redir_esc=y#v=onepage&q=cross-reference%20table%20corrupted%20file%20pdf&f=false I edited the original file release 1.0.3 I changed all @crlf whit chr(10) Global $PDF_VERSION = "%PDF-1.5" & @CRLF & "%" & ChrW(199) & ChrW(200) & ChrW(201) & ChrW(202) whit Global $PDF_VERSION = "%PDF-1.5" & chr(10) & "%" & ChrW(226) & ChrW(227) & ChrW(207) & ChrW(211) into Func _BeginPage __ToBuffer("<< /Length " & $intPage + 2 & " 0 R >>" & @CRLF & "stream") whit __ToBuffer("<<"&chr(10)&"/Length >>stream") into Func _ClosePDFFile() __ToBuffer("xref") __ToBuffer("0 " & $_iMaxObject+1) __ToBuffer("0000000000 65535 f") For $i = 1 To $_iMaxObject __ToBuffer($aXREF[$i]) Next __ToBuffer("trailer" & @CRLF & _ "<< /Size " & $_iMaxObject + 1 & "/Info 1 0 R" & "/Root 2 0 R" & ">>") __ToBuffer("startxref" & @CRLF & StringLen("startxref" & @CRLF & $_Buffer & "%%EOF" & @CRLF) + 6) $_FileName = FileOpen($PDF_NAME,18) FileWrite($_FileName, $_Buffer & "%%EOF" & @CRLF) FileClose($_FileName) If $_bOpen Then ShellExecute($PDF_NAME) whit dim $position_xref=stringlen($_Buffer) __ToBuffer("xref") __ToBuffer("0 " & $_iMaxObject+1) __ToBuffer("0000000000 65535 f"&chr(13)) For $i = 1 To $_iMaxObject __ToBuffer($aXREF[$i]&chr(13)) Next __ToBuffer("trailer" & chr(10) & _ "<< /Size " & $_iMaxObject + 1 & "/Info 1 0 R" & "/Root 2 0 R" & ">>") __ToBuffer("startxref" & chr(10) & $position_xref & chr(10) & "%%EOF") $_FileName = FileOpen($PDF_NAME,18) FileWrite($_FileName, $_Buffer) FileClose($_FileName) $_Pages = "" $_sPage = "" $_sFONT = "" $_Image = "" $_sObject = "" $_iResource = "" $_Buffer = "" If $_bOpen Then ShellExecute($PDF_NAME) into Func _LoadResImage __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8" & " /Length " & $iObj + 1 & " 0 R" & ">>") __ToBuffer("stream" & @CRLF & $ImgBuf & @CRLF & "endstream") whit __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8"&chr(10)&"/Length "&stringlen($ImgBuf)&">>stream") __ToBuffer($ImgBuf) __ToBuffer("endstream") into Func _StartObject __ToBuffer("<< /Type /XObject /Subtype /Form /FormType 1 /Name /" & $sAlias & " /BBox [" & __ToStr($__SetMargin) & " " & __ToStr($__SetMargin) & " " & __ToStr($_PageWidth - $__SetMargin) & " " & __ToStr($_PageHeight - $__SetMargin) & "] /Matrix [1 0 0 1 0 0] /Length " & $i + 1 & " 0 R >>" & @CRLF & _ "stream") whit __ToBuffer("<< /Type /XObject /Subtype /Form /FormType 1 /Name /" & $sAlias & " /BBox [" & __ToStr($__SetMargin) & " " & __ToStr($__SetMargin) & " " & __ToStr($_PageWidth - $__SetMargin) & " " & __ToStr($_PageHeight - $__SetMargin) & "] /Matrix [1 0 0 1 0 0]"&chr(10)&"/Length >>stream") into Func __InitObj $aXREF[$iObj] = StringRight("0000000000" & StringLen($_Buffer)+$_Offset+$iObj+1, 10) & " 00000 n" whit $aXREF[$iObj] = StringRight("0000000000" & StringLen($_Buffer), 10) & " 00000 n" into Func _EndObject() $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() __InitObj() __ToBuffer($_iTmpOffset) __EndObj() whit $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() dim $aArray1=_StringBetween($_Buffer,"/Length >>stream","endstream") dim $stringlen for $i=0 to ubound($aArray1)-1 $stringlen=$stringlen+stringlen($aArray1[$i]) next $_Buffer=StringReplace($_Buffer,"/Length >>stream","/Length "&$stringlen-1&">>stream") __InitObj() __ToBuffer($_iTmpOffset) __EndObj() into Func _EndPage() $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() ; Scrie dimensiunea __InitObj() __ToBuffer($_iTmpOffset) __EndObj() whit $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() dim $aArray1=_StringBetween($_Buffer,"/Length >>stream","endstream") dim $stringlen for $i=0 to ubound($aArray1)-1 $stringlen=$stringlen+stringlen($aArray1[$i]) next $_Buffer=StringReplace($_Buffer,"/Length >>stream","/Length "&$stringlen-1&">>stream") ; Scrie dimensiunea __InitObj() __ToBuffer($_iTmpOffset) __EndObj() so my pdf files are compatible with "Acrobat Reader X" and "flipping pdf reader" and "sumatra pdf" and "pdf-xchange viewer" I am attaching the modified file udf MPDF_UDF.au3 Gianni 1 To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted March 12, 2014 Share Posted March 12, 2014 (edited) @bdr529 Perfect Edited March 12, 2014 by Emiel Wieldraaijer bdr529 1 Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Qwerty212 Posted March 14, 2014 Share Posted March 14, 2014 @bdr529 Link to comment Share on other sites More sharing options...
auzpater Posted May 2, 2014 Share Posted May 2, 2014 hi, I found some bugs using the function _Paragraph: Carriage return does not appear Accented characters space here is the code to test it, and the screenshot of pdf generated with bugs #include "MPDF_UDF.au3" $sTxt = "these accented characters: à ì ò ù it is creating problems" $sTxt2 = "Another problem with the carriage return,"&@CRLF&"which is not displayed" $fileName = @ScriptDir&"\___prova.pdf" ; set the properties for the pdf ----------------------------------------------------- _SetTitle("titolo") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_CM) _SetPaperSize("A4") _SetZoomMode($PDF_ZOOM_CUSTOM,65) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_TWO) ;initialize the pdf _InitPDF($fileName) ;fonts: _LoadFontTT("_Arial", $PDF_FONT_ARIAL) _LoadFontTT("_TimesT", $PDF_FONT_TIMES) _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI) _LoadFontTT("_Garamond", $PDF_FONT_GARAMOND) ;start a page _BeginPage() _Paragraph($sTxt2, 1, 24, 10, "_Arial", 14, 0) _Paragraph("_Arial: "&$sTxt, 1, 22, 10, "_Arial", 14, 0) _Paragraph("_TimesT: "&$sTxt, 1, 20, 10, "_TimesT", 14, 0) _Paragraph("_Calibri: "&$sTxt, 1, 18, 10, "_Calibri", 14, 0) _Paragraph("_Garamond: "&$sTxt, 1, 16, 10, "_Garamond", 14, 0) _EndPage() _ClosePDFFile() Does anyone have suggestions? Link to comment Share on other sites More sharing options...
BlackShadow Posted May 16, 2014 Share Posted May 16, 2014 I have been using the version modified by bdr529 successfully, but I have a slight issue with the image quality that I can't seem to figure out. I'm not sure if large JPG images gets degraded when added to a PDF, one big image per page, or if there is some other issue. But when I look at the PDF (in FoxIt) the images there have a lower quality than the original JPGs. The actual code is pretty small and simple: (Xmax and Ymax is the size in pixels of the JPG) _SetTitle("PDF") _SetSubject("PDF") _SetKeywords("PDF") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_CM) _SetPaperSize("CUSTOM",$Xmax, $Ymax) _SetZoomMode($PDF_ZOOM_FULLPAGE) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) ;initialize the pdf _InitPDF(@ScriptDir & "\PDF.pdf") $time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC For $i = 1 to $pageCount _LoadResImage("img"&$time&$i, @ScriptDir & "\tmp\" & $i & ".jpg") Next For $i = 1 to $pageCount _BeginPage() ;scale image to paper size! _InsertImage("img"&$time&$i, 0, 0, _GetPageWidth()/_GetUnit(), _GetPageHeight()/_GetUnit()) _EndPage() Next _ClosePDFFile() On a sidenote, there is a small issue with MPDF when it comes to making several PDF without restarting, this is easily solved by resetting the page count with: Global $_Pages = 0 ; Which prob should have been done in _InitPDF. Link to comment Share on other sites More sharing options...
rsnuke Posted August 11, 2014 Share Posted August 11, 2014 I'm using the latest; Title .........: MIPDF ; AutoIt Version : 3.3.6.1 ; Description ...: Generate pdf using just AutoIt functions. ; Author(s) .....: Mihai Iancu (taietel at yahoo dot com) ; Version .......: 1.0.3 ; Last Rev. .....: August 10, 2011 It seems like in the latest Autoit3 v3.3.12 _Iif is undefined? How do we fix this? _Iif($_sFONT <> "", "/Font<<" & $_sFONT & ">>", "") & _ MPDF_UDF.au3"(252,54) : error: _Iif(): undefined function. Link to comment Share on other sites More sharing options...
funkey Posted August 11, 2014 Share Posted August 11, 2014 I'm using the latest; Title .........: MIPDF ; AutoIt Version : 3.3.6.1 ; Description ...: Generate pdf using just AutoIt functions. ; Author(s) .....: Mihai Iancu (taietel at yahoo dot com) ; Version .......: 1.0.3 ; Last Rev. .....: August 10, 2011 It seems like in the latest Autoit3 v3.3.12 _Iif is undefined? How do we fix this? _Iif($_sFONT <> "", "/Font<<" & $_sFONT & ">>", "") & _ MPDF_UDF.au3"(252,54) : error: _Iif(): undefined function. Instead of _lif() you can use new build in syntax: ($_sFONT <> "") ? ("/Font<<" & $_sFONT & ">>") : ("") Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Zedna Posted August 17, 2014 Share Posted August 17, 2014 Instead of _lif() you can use new build in syntax: Or instead of modifying code in UDF just add _lif() Func _Iif($fTest, $vTrueVal, $vFalseVal) If $fTest Then Return $vTrueVal Else Return $vFalseVal EndIf EndFunc ;==>_Iif Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
SDothard Posted October 16, 2014 Share Posted October 16, 2014 HI I'm pretty new to Autoit, and I have a question about creating pdf's from my application. I got the udf working, but I need to know if this is possible. take an existing pdf that accepts user input (name, dob, date, etc) somehow import that pdf template into autoit call data from autoit to populate the data fields then print the pdf template with the autoit data in the data fields Is this possible with this udf? I appreciate any help. Link to comment Share on other sites More sharing options...
SDothard Posted October 16, 2014 Share Posted October 16, 2014 I think I may have answered my own question. Should I first convert my pdf into an image and then use the udf to import an image and overlay data where the data fields are? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now