FPDF with Classic ASP, Image Error - asp-classic

Let's preface this post by saying... Yes, I know I'm a dinosaur for using Classic ASP in this day and age!
I'm using FPDF.asp to generate a PDF on the fly.
Everything works fine and as expected on my test server. On my live server, however, I encounter an error, if I try to output an image as part of my PDF. I know the syntax is correct, since it works on the test server as it should.
The error I receive on my live server is: "File does not begin with '%PDF-'."
If I comment out the line that adds the image, the file loads up properly and error-free!
Does anyone have any idea, as to what may need to be corrected on the live server to eliminate this problem???
Any help would be most appreciated.
Mitch

Update!
Not sure why having an image or not makes the difference, BUT the solution turned out to be that I had some HTML code mixed in with the output and this caused FPDF to fail when an image was included.
Removed the HTML code and problem solved!
-Mitch

Related

Browser Displaying Plain Text

When I view the site www.redfuryrevenge.com with a browser, I see only plain text, as if there is no CSS. When I view it locally using Macrabbit Espresso preview, it looks fine. I tried finding the error using Firefox console, debugger, etc., but nothing pops up for me.
I've never seen anything like this (except for a missing CSS file reference).
Please advise.
it seems that for some reason you need to put the full root.
You can fix it adding the ./
Use the following syntax:
href="./css/style.css"
I've tried it and it should fix your issue

Why my image source is not working for my current local machine but it's working for the web sources?

I have a div and I want to show images as innerhtml using the back end C# code. So that I can generate them as I want them to. In here for innerhtml everything is running fine but the images. While I am giving it a path from my current localhost the images are not showing but while I am putting an web url its working why?
Even if I tested taking the suggestion from the visualstudio like I put a static image in front end and took its path but its still not working. I user the server.mappath(test) this function too.
test = "App_Data/images/37id4.jpg";
divfifth.InnerHtml ="<img src='"+test+"' />";
This says the path is not found here is my code given.
if anyone can suggest me to generate these in better way please suggest.
Hello #Borshon Aeolus Saydur , Its a nice question. Try to give add path like "~/images/.." format. instead of "Images/..".
i have solved it by moving my image folder one layer up.although i dont know what was the wrong in previous layer.but its now working after moving it to its upper layer..

classic asp in vb script HTML Render Error

ABCpdf error '80070000'
HTML render is blank.
D:\TPABENEFITS\WEB810678\REPORTS../../pages/reports/makepdf.asp, line 240
Hi, recently our website started showing this errors:
ABCpdf error '80070000'
HTML render is blank.
/admin/trucks_printpdfpayments_pdf.asp, line 12
i looked up the error to see what would need to be done to fix it, please note i have no idea how asp works, the original programer of this site is no longer with the company.
Here is a link to the suppourt website: http://www.websupergoo.com/support.htm#security
on 6.7 on ABCpdf it tells me i can add a line of code before (i think the line having an error)
the code would be: Doc.SetInfo 0, "HostWebBrowser", "0"
i have tried and tested it on several places on the file, though since i have no idea what the code is doing i would not really know were to place it.
on a side note, if you know of any places online to study this code let me know

Outputting Images in ASP FPDF problem

Hi
I'm attempting to use the ASPFPDF class to output an image on a pdf using the very simple code below:
<!--#include file="fpdf.asp"-->
<%
Dim pages
Dim pdf
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "P", "mm", "A4"
pdf.SetPath "fpdf/"
pdf.Open()
pdf.AddPage("P")
pdf.Image "invoiceheader.jpg"
pdf.Output ()
%>
When run, this script should open the pdf but with Adobe Reader I get a "File does not begin with %pdf" message. I've tried using other readers with similar results.
If I remove the image line and output some text (e.g. pdf.Cell 40,5,"Date",0,1,"R"), everything works perfectly.
Anyone got any ideas before I go mad!
Thank you.
Try this one
pdf.Image "IMAGES/invoiceheader.jpg", 140, 22, 50, 40
Here 140 is the x position, 22 is the y-position 50 is the width and 40 is the height.
I don't know AspFPdf, but don't you need to specify a folder where the image is to be found ?
Did you try ?
pdf.Image "fpdf/invoiceheader.jpg"
As I said, I don't know the component, just my thoughts (although you have propably tried this yourself).
[EDIT] Look at the website of Asp Fpdf and saw the following in the documentation:
file
Path or URL of the image.
Asp fPdf : Image parameter
Anyway: thanks for pointing me in the direction of this component (even though this was not your intention). I can use this too ;-)
Just thought I'd update people as I've spent ages and have finally got this working. What you don't see due to random error messages is that the FPDF application creates a temporary PDF as it's building it. By default, it will create it in the same folder as your asp page that runs it.
e.g. My page was in my web root \createpdf.asp
I worked out that it was trying to create a file called D10456.tmp (name changes each time) in my web root but it couldn't due to security.
I added an output file name and changed the security in another folder to allow write access and it worked first time.
Code for output file:
pdf.Output server.mappath("pdfs\list.pdf"),"F"
The PDFS folder must have write access to work.
Hope that helps people.
The answer by Paul is also correct for the format of adding an image in ASP.
Also, I had to change the images.asp file which is located in the includes directory.
I had to change the line:
this.Buffer.LoadFromFile(Server.MapPath("\\") + ("\\") + ("Images") + ("\\") + pFileName);
to
this.Buffer.LoadFromFile(Server.MapPath(pFileName));
because it was looking in the wrong folder for my images.
The answer to the above question is that the FPDF seems to need to be on a fully qualified domain - I was running on a machine with using a custom hosts file to point the URL at the development server. As soon as I moved the code to the live server, everything worked!
I don't fully understand why, but this might help someone else...
I found that the only way I could add images was as follows:-
pdf.Image "./byimage.jpg",x,y,width
This is how i manage to display my image in ASP classic page:
pdf.Image "fpdf/header.jpg", 10, 10,80,20, "jpg"
if not mistakes, this is how to define the variables (correct me if i'm wrong):
pdf.image "folder/image.type", x-coordinate, y-coordinate, img width, img height, "image type"
hope it helps. because i've spent many days just to find how to display the image in my asp classic page..

response.write only working IE for ASP.NET

I'm using uploadify (http://www.uploadify.com/) to upload video to my site then convert them into *.flv using ffmpeg and play preview. But it dosen't fully working with firefox, chrome or safari.
uploadify provides a onComplete interface, so when the script (.ashx, .php) used on your site for saving uploaded files. you can use response.write("blabla") or (echo "blabla") to invoke the javascript function that registed as OnComplete.
i have test with few video files like avi, mpg, mp4, they are less then 50mb,and they all worked with all 4 browsers. However, when i was trying to upload a 75mb mp4 file, it worked in IE, but didn't working in other three. I can see the .flv file has been create in the upload folder, i can see debug messsage output after response.write("blabla"), but the javascript function was not invoked. i.e. the preview didn't play.
anyone knows why? is there a timeout or something on response.write so after a period of time it wont work? e.g. 75mb file took longer time to convert than other smaller size file i tried.
thansk
Could be a timeout from the server or caching issue. Or an incorrect uploadifiy property as stated here
after a deeper looking in the source code, and googling around. the problem is narrow down on
DataEvent.UPLOAD_COMPLETE_DATA and firefox issues
someone reported bug
http://bugs.adobe.com/jira/browse/FP-1419

Resources