|
Damn.. Unbelievable, I just implemented this entire thing. Took like half an hour to find out that it gives me the exact same error. {"A generic error occurred in GDI+."} System.Exception {System.Runtime.InteropServices.ExternalException}
Any other ideas?
|
|
|
|
|
What happened to your other message, the one with:
Jordy "Kaiwa" Ruiter wrote: Woah.. You're right! Why didn't I think of something like that? Well I'm gonna give it a try then
I think I've stared at the same code for too long to come up with this! I'll let you know the outcome!
you are not supposed to remove messages, just keep the thread flow intact, as laid out in the forum guidelines.
Jordy "Kaiwa" Ruiter wrote: the exact same error.
you should provide more information; where does this occur? under what circumstances?
is it always the same frame of the same image that fails? try some others. What is the source of your multiTIFF?
Everything that fails inside GDI+ is reported as a "Generic error", making it hard to pinpoint. Is there some other utility that reads and shows all pages correctly?
If you suspect an early Dispose() call, just remove them all to see if that helps; this is only a test, NOT a recommendation.
|
|
|
|
|
Ah sorry, I figured a double post wasn't really nice either. But anyway. I found a "fix". It seems that if I use Bitmap.FromFile() to open the TIFF file that browsing through pages is possible.
And the first post explained exactly the issue, with it being the same error i ment the same function that crashes SelectActiveFrame()
I'm going to try and work it out with Bitmap.FromFile() instead of Bitmap.FromStream() .
|
|
|
|
|
IIRC there is a little note in the FromStream() documentation that states one should keep the stream open as long as the image is alive; you now have discovered a very good reason for this unexplained statement.
|
|
|
|
|
That actually makes alot of sense yes. I solved it with a different approach just working out the last issues with dragging and dropping
Thanks for your help! (A copy of the code will soon be updated in my article if you are interested )
|
|
|
|
|
|
Hi,
I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser.
Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL.
Thanks in Advance!!
|
|
|
|
|
you can zip that pdf then user download it wirhout opening in another browser
|
|
|
|
|
You can use the Content-Disposition HTTP header to force the file to download and not open in the browser. No zipping required.
|
|
|
|
|
If you are using ASP.NET you can create an aspx site where you check if the user
has the right to download/see the pdf (maybe through a temp guid). If he has the right, then you can
send this pdf through the response stream to the client pc.
Example:
.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetPDF.aspx.cs" Inherits="[namespace].GetPDF" %>
.cs
public partial class GetPDF : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.Clear();
Response.ContentType = "application/pdf";
Response.BufferOutput = true;
Response.Cache.SetNoServerCaching();
Response.Cache.SetNoStore();
Response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception)
{
}
}
}
Maybe the user sees the url "http://.../GetPDF.aspx?querystring" but through your check, copy and paste the url
will not work. (You could create a temp guid to access the pdf for the user, provide it in the querystring and delete
this temp guid after downloading. On the next call of this url the user will not be able to download it again.)
Hope this helps.
Edit:
In addition to the example above, you can also use the session object to check if the user has the rights to access the pdf file. Just set a session value (like Session["UserCanAccessPDF"] = true; ) on link click event and check this session value on GetPDF::Page_Load. If the session value is invalid or not set, just redirect to an error page (or something else). If the value is valid, send the pdf trough the stream and delete the session value.
Greetings
Covean
modified on Thursday, April 29, 2010 7:01 AM
|
|
|
|
|
Assuming ASP.Net...
Create a button. In the click handler, write the file to the HTTP response, as the previous poster suggested. That way, you aren't using a different URL. The only way they can get the file would be to click the button. You can have whatever logic you like to decide when to display that button, or if they manage to click the button when they are not allowed, you can add additional validation to prevent the download. You could, for example, validate that the user has never downloaded the PDF before so that they can't download it a second time. If they have already downloaded it, you could show a message that says "sorry, but you are only allowed to download this PDF once". The PDF data you return can come from the server file system or from a database on the server (or even from another server). Where you want to get the PDF from is up to you.
|
|
|
|
|
|
Not sure that's what the OP is after, but perhaps you should redirect your answer to the OP anyway. It's certainly going to do me no good.
|
|
|
|
|
ups... sorry aspdotnetdev! ok! my answer was:...............
Perhaps you can use Server.Transfer("url");[^] instead of Response.Redirect("url");.....
good luck
|
|
|
|
|
Hi.
I have an array of images like:
Image[] images = new Image[3];
After populating it with three images, i want to remove all of them and prepare it for the next set of three images by clearing the array. i have tried:
images.Clear();
as in an array but this does not work. How do i remove the images?
Thank you in advance.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Have you tried repeating step 1
images = new Image[3];
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Wamuti wrote: How do i remove the images?
What do you mean by "remove"? you can't remove anything from an array, each element will be there, all you can do is replace it, possibly by null.
If you want a variable number of elements, use a real collection such as a List<Image>
If you are worried about memory clean-up (and you should), then call Dispose() on each non-null element before replacing it by something else (unless the same image is still needed elsewhere).
|
|
|
|
|
If you want the elements to vary and you want to keep using an array and you don't want to reference a new array, you could always try:
Image[] images = new Image[3];
Array.Resize<Image>(ref images, 0);
Array.Resize<Image>(ref images, 4);
|
|
|
|
|
Two days in row, two different questions (yesterday's problem is solved by the way )
This is another one where I need some creative ideas...
I need to find all groups of items in an array. In this case same items in a different order means same group. The array/set/... is prepared by some methods that are executed earlier. This means I could start with 1 item, but with 250 items as well.
Let's suppose the generated array/set/... contains 5 items A, B, C, D and E. The groups I should get as result are the following:
A - B - C - D - E
AB - AC - AD - AE - BC - BD - BE - CD - CE - DE
ABC - ABD - ABE - ACD - ACE - ADE - BCD - BCE - BDE - CDE
ABCD - ABCE - ABDE - ACDE - BCDE
ABCDE
I don't need to reuse the combinations afterward. I just need the algorithm to perform a check routine on each group (and it occurs on only one place in my program). A little like "loop { check(group) }"
Thanks in advance for your ideas!
modified on Friday, April 30, 2010 4:21 AM
|
|
|
|
|
That looks like the power set minus the empty set
How about (in pseudocode - untested):
void TestAll(int i)
{
if (i == numberOfItems)
{
check(test-set)
return
}
TestAll(i + 1)
add input[i] to the test-set
TestAll(i + 1)
remove input[i] from the test-set
}
It includes the empty set but oh well..
Just an idea - I can't test it now though because I have to go, I'll be back in 8 hours or so
|
|
|
|
|
At first glance it looks good but I don't really understand what you mean. Could you (or somebody else) post a code snippet? Thanks in advance!
|
|
|
|
|
Here's another way of looking at it:
You have a binary number with as many bits as you have items. E.g. for ABCDE you'd have a 5-bit binary number. You then go through all the possible binary numbers of this length (i.e. the power set):
00001
00010
00011
00100 etc...
(In this case you'd ignore 00000 (no items)).
Where there's a 1 bit, you select the item. So the first four groups would be:
E (from 00001)
D (from 00010)
DE (from 00011)
C (from 00100)
This will go through every possible group of selections from the items, without regard to order.
|
|
|
|
|
With my Combinations extension method, I can do:
char[] b = new char[] { 'A' , 'B' , 'C' , 'D' , 'E' } ;
for ( int i = 1 ; i <= b.Length ; i++ )
{
foreach ( System.Collections.Generic.IList<char> a in b.Combinations ( i ) )
{
foreach ( char c in a )
{
System.Console.Write ( "{0} " , c ) ;
}
System.Console.WriteLine() ;
}
}
|
|
|
|
|
I've continued looking while I was waiting for answers and I found a quite simple way to do this. For my program, I had to build in a treshold calculation for performance purposes, but that's already done. Just the loops:
class ComboSearcher {
private string[] _arCombos;
private int[] _arIndeces;
private string[] _arSourceArray;
public ComboSearcher(string[] SourceArray) {
_arSourceArray = SourceArray
}
private void AddItemInt(ref int[] ArrayToUpdate, int ItemToAdd) {
int[] tmpArray;
tmpArray = new string[ArrayToUpdate.length];
for(int i=0; i<ArrayToUpdate.length; i++) {
tmpArray[i] = ArrayToUpdate[i];
}
ArrayTuUpdate = tmpArray;
}
private void CutArrayInt(ref int[] ArrayToCut, int NewLength) {
int[] tmpArray;
tmpArray = new int[NewLength];
for(int i=0; i<NewLengh; i++) {
tmpArray[i] = ArrayToCut[i];
}
ArrayToCut = tmpArray;
}
private void SubCheck(int IndexNumber) {
int i, j, minCount;
_arCombos = new string[0]
AddItemInt(_arIndeces, 0);
if(_arIndeces.lengh > 1) {
minCount = _arIndeces[_arIndeces.length - 2);
}
else {
minCount = 0;
}
for(i=minCount; i<_arSource.length; i++) {
_arIndeces[IndexNumber] = i;
for(j=0; j<=IndexNumber; j++) {
}
if(_arIndeces.length<_arSourceArray.length) {
CutArrayInt(_arIndeces, IndexNumber + 1);
}
}
}
public string[] Combinations() {
_arCombos = null;
SubCheck(0);
return _arCombos
}
}
Usage:
ComboSearcher cboSearch;
cboSearch=new ComboSearcher(source);
target=ComboSearcher.Combinations();
|
|
|
|
|
If you have 64 items or less (you better hope so, otherwise it will take forever) you could just use the bits in an ulong - that might complicate your check method a bit depending on your datastructures though
|
|
|
|